home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-02 / swagabc.zip / CURSOR.SWG < prev    next >
Text File  |  1993-05-29  |  10KB  |  1 lines

  1. SWAGOLX.EXE (c) 1993 GDSOFT  ALL RIGHTS RESERVED 00008         CURSOR HANDLING ROUTINES                                          1      05-28-9313:36ALL                      SWAG SUPPORT TEAM        Cursor SIZE/COLOR        IMPORT              7           {> And how can I hide my cursor ? I know it's something With INT 10 butπ> that's all I know...ππTry this:πSType 'C' or 'M' - Color or monchrome displayπSize 'S' or 'B' or 'O' cursor small, big, or none (invisible)π}πUses Dos;ππProcedure CursorSize(SType, Size : Char);ππVarπ  Regs : Registers;π  i : Integer;ππbeginπ  Size := UpCase(Size);π  if UpCase(SType) = 'M' thenπ    i := 6π  ELSEπ   i := 0;ππRegs.AH := $01;πCASE Size ofπ'O' :π  beginπ   Regs.CH := $20;π   Regs.CL := $20;π  end;π'B' :π  beginπ   Regs.CH := $0;π   Regs.CL := $7 + i;π  end;π'S' :π  beginπ   Regs.CH := $6+i;π   Regs.CL := $7+i;π  end;πend;πIntr($10, Regs);πend;ππbeginπ  CursorSize('C','B');π  readln;πend.                                                                                       2      05-28-9313:36ALL                      SWAG SUPPORT TEAM        CUSOR Handling #1        IMPORT              22          Unit cursor;ππ(*π *  CURSOR v1.1 - a Unit to provide extended control of cursor shape.π *π *  Public Domain 1991 by John Giesbrecht (1:247/128)π *π *  Notes:π *π *  - This version requires Turbo Pascal 6.0 or later.π *  - These routines affect only the cursor on page 0.π *  - This Unit installs an Exit Procedure which restores the cursorπ *    to its original shape when the Programme terminates.π *)ππInterfaceππProcedure cursoroff;πProcedure cursoron;           (* original cursor shape *)ππProcedure blockcursor;πProcedure halfblockcursor;πProcedure linecursor;         (* Default Dos cursor    *)ππProcedure setcursor(startline, endline : Byte);πProcedure getcursor(Var startline, endline : Byte);ππ(********************************************************************)ππImplementationππConstπ  mono = 7;ππVarπ  origstartline,π  origendline,π  mode : Byte;π  origexitproc : Pointer;ππ(********************************************************************)πProcedure setcursor(startline, endline : Byte); Assembler;ππAsmπ  mov ah, $01π  mov ch, startlineπ  mov cl, endlineπ  int $10πend;π(********************************************************************)πProcedure getcursor(Var startline, endline : Byte); Assembler;ππAsmπ  mov ah, $03π  mov bh, $00π  int $10π  les di, startlineπ  mov Byte ptr es:[di], chπ  les di, endlineπ  mov Byte ptr es:[di], clπend;π(********************************************************************)πProcedure cursoroff;ππbeginπ  setcursor(32, 32);πend;π(********************************************************************)πProcedure cursoron;ππbeginπ  setcursor(origstartline, origendline);πend;π(********************************************************************)πProcedure blockcursor;ππbeginπ  if mode = monoπ    then setcursor(1, 12)π    else setcursor(1, 7);πend;π(********************************************************************)πProcedure halfblockcursor;ππbeginπ  if mode = monoπ    then setcursor(7, 12)π    else setcursor(4, 7);πend;π(********************************************************************)πProcedure linecursor;πbeginπ  if mode = monoπ    then setcursor(11, 12)π    else setcursor(6, 7);πend;π(********************************************************************)πProcedure restorecursor; Far;ππbeginπ  system.exitproc := origexitproc;π  cursoron;πend;π(**  I N I T I A L I Z A T I O N  ***********************************)πbeginπ getcursor(origstartline, origendline);π Asmπ  mov ah, $0Fπ  int $10π  mov mode, alπ end;π origexitproc := system.exitproc;π system.exitproc := addr(restorecursor);πend.π                                                                                                                      3      05-28-9313:36ALL                      SWAG SUPPORT TEAM        Cursor Handling #2       IMPORT              15          MN> Anyone have any code on hiding the cursor and then bringing it back.ππMN>                               -+- Mike Normand -+-πππI've seen many replies to this but all suffer the same disadvantage: they allπassume you know the size of the cursor. A little bit debugging BASIC revealsπwhat's up (by the way, you'll find it described in some good books): you haveπto set bit 5 For the start line and the cursor will disappear since this valueπis not allowed. To get the cursor back again, clear bit 5 again. Use thisπsolution, if you Really just want to turn on/off the cursor. CursorOn/CursorOffπdo *not* change the cursor shape!!! and do *not* need an external Variable toπmanage this.ππThe  PUSH BP / POP BP  is needed For some *very* old BIOS versions using CGA/πmonochrome :-( display, that trash BP during an INT 10h. If you just want doπsupport EGA/VGA :-) and better, just push 'em out.ππ-----------------------------------------------------πProcedure CursorOff; Assembler;πAsmπ    push bp            { For old BIOSs }π    xor  ax, axπ    mov  es, axπ    mov  bh, Byte ptr es:[462h]  { get active page }π    mov  ah, 3π    int  10h           { get cursor Characteristics }π    or   ch, 00100000bπ    mov  ah, 1π    int  10h           { set cursor Characteristics }π    pop  bp            { restore bp For old BIOSs }πend;ππProcedure CursorOn; Assembler;πAsmπ    push bp            { old BIOSs like this... }π    xor  ax, axπ    mov  es, axπ    mov  bh, Byte ptr es:[462h]  { get active page }π    mov  ah, 3π    int  10h           { get cursor Characteristics }π    and  ch, 00011111bπ    mov  ah, 1π    int  10h           { set cursor Characteristics }π    pop  bp            { ...and this, too }πend;π                                                                                 4      05-28-9313:36ALL                      SWAG SUPPORT TEAM        Show/Hide Cursor         IMPORT              4           Uses Crt;ππVarπ  Continue : Char;ππProcedure HideCursor; Assembler;πAsmπ  MOV   ax,$0100π  MOV   cx,$2607π  INT   $10πend;ππProcedure ShowCursor; Assembler;πAsmπ  MOV   ax,$0100π  MOV   cx,$0506π  INT   $10πend;ππbeginπ  Writeln('See the cursor ?');π  Continue := ReadKey;π  HideCursor;π  Writeln('Gone! ');π  Continue := ReadKey;π  ShowCursor;πend.                                   5      05-28-9313:36ALL                      SWAG SUPPORT TEAM        Cursor Size & Detect     IMPORT              9           {πSEAN PALMERπ}ππunit cursor; {Public domain, by Sean Palmer aka Ghost}ππinterfaceππvarπ  maxSize : byte;ππprocedure setSize(scans : byte);  {set size from bottom, or 0 for off}πprocedure detect;     {get max scan lines by reading current cursor}ππimplementationππprocedure setSize(scans : byte);πvarπ  t : byte;πbeginπ  if scans = 0 thenπ    t := $20π  elseπ    t := maxSize - scans;π  asmπ    mov ah, 1π    mov bh, 0π    mov ch, tπ    mov cl, maxSizeπ    dec clπ    int $10π  end;πend;ππprocedure detect; assembler;πasm  {do NOT call while cursor's hidden}π  mov ah, 3π  mov bh, 0π  int $10π  inc clπ  mov maxSize, clπend;ππbeginπ  detect;πend.ππprogram test;πusesπ  cursor;πbeginπ  writeln(cursor.maxSize);π  cursor.setSize(cursor.maxSize);π  readln;        {block}π  cursor.setSize(0);π  readln;                     {hidden}π  cursor.setSize(cursor.maxSize div 2);π  readln;  {half}π  cursor.setSize(2);π  readln;                     {normal}πend.π                                                                        6      05-28-9313:36ALL                      SWAG SUPPORT TEAM        Cursor Show/Hide #2      IMPORT              5             Procedure HideCursor;  assembler;π  asmπ    mov      ah,$01  { Function number }π    mov      ch,$20π    mov      cl,$00π    Int      $10     { Call BIOS }π  end;  { HideCursor }πππ  Procedure RestoreCursor;  assembler;π  asmπ    mov      ah,$01  { Function number }π    mov      ch,$06  { Starting scan line }π    mov      cl,$07  { Ending scan line }π    int      $10     { Call BIOS }π  end; { RestoreCursor }π                                                                                                 7      05-28-9313:36ALL                      SWAG SUPPORT TEAM        Find The Cursor          IMPORT              3           Usesπ  Dos;ππProcedure FindXY(Var X, Y : Byte; Page : Byte);π{X = Row of Cursor}π{Y = Colum of Cursor}π{Page = Page Nummber}πVarπ  Regs : Registers;πbeginπ  Regs.Ah := 3;π  Regs.Bh := Page;π  intr($10, Regs);π  X := Regs.Dl;π  Y := Regs.Dh;πend;π          8      05-28-9313:36ALL                      SWAG SUPPORT TEAM        Spin The Cursor INPUT    IMPORT              13          Program SpinKey;ππUses Crt;π(*   ^^^^π     This is only For "beautifying" the stuff. XCrt has the Procedures:π     HideCursorπ     ShowCursorπ     but they are not Really important, perhaps you have youre ownπ*)ππConstπ  SpinChar : Array [1..4] of Char = ('│','/','─','\');ππFunction ReadKeySpin(Wait : Byte) : Char;πVarπ  X,Y  : Byte;π  Num  : Byte;π  Ch   : Char;πbeginπ  Num := 1;                               (* initialize SpinChars  *)π  X   := WhereX;                          (* Where am I ??         *)π  Y   := WhereY;π  Repeatπ    Write(SpinChar[Num]);           (* Spin the Cursor       *)π    GotoXY(X, Y);                   (* Go back               *)π    Delay(Wait);                    (* Wait, it's to fast!   *)π    Write(#32);                     (* Clean Screen          *)π    GotoXY(X, Y);                   (* Go back               *)π    Inc(Num);                       (* Next SpinChar, please *)π    if Num = 5 then Num := 1;       (* I have only 5 Chars   *)π  Until KeyPressed;π  Ch := ReadKey;                        (* Get the pressed Key   *)π  Write(Ch);                            (* and Write it to screen*)π  ReadKeySpin := Ch;                    (* give a result         *)πend;ππFunction ReadStringSpin : String;πVarπ  Help : String;π  Ch   : Char;π  i    : Byte;πbeginπ  Help := '';π  Repeatπ    Ch := ReadKeySpin(40);π    if Ch <> #13 then Help := Help + Ch;π  Until Ch = #13;π  ReadStringSpin := Help;π  WriteLn;πend;ππVarπ  TestString : String;πbeginπ  TestString := ReadStringSpin;πend.π